# product/urls.py

from django.urls import path
from .views import (
    ProductListCreateAPIView, ProductRetrieveUpdateDestroyAPIView,
    CartView, CartItemCreateView, CartItemUpdateDeleteView,OrderListView, OrderCreateView,
    UserProductsListView, OrderDetailView, OrderUpdateView
)

urlpatterns = [
    # 商品相关URL
    # 列表和创建：GET / 和 POST /
    path('', ProductListCreateAPIView.as_view(), name='product-list-create'),

    # 详情、更新和删除：GET/PUT/PATCH/DELETE /<int:pk>/
    path('<int:pk>/', ProductRetrieveUpdateDestroyAPIView.as_view(), name='product-detail'),

    # 购物车相关URL
    # 获取购物车详情：GET /cart/
    path('cart/', CartView.as_view(), name='cart-detail'),

    # 添加商品到购物车：POST /cart/items/
    path('cart/items/', CartItemCreateView.as_view(), name='cart-item-create'),

    # 更新或删除购物车商品：GET/PUT/PATCH/DELETE /cart/items/<int:pk>/
    path('cart/items/<int:pk>/', CartItemUpdateDeleteView.as_view(), name='cart-item-update-delete'),
    path('orders/', OrderListView.as_view(), name='order-list'),

    # 从购物车创建订单：POST /orders/create/
    path('orders/create/', OrderCreateView.as_view(), name='order-create'),

    # 订单详情：GET /orders/<int:pk>/
    path('orders/<int:pk>/', OrderDetailView.as_view(), name='order-detail'),

    # 订单更新：PUT/PATCH /orders/<int:pk>/
    path('orders/<int:pk>/update/', OrderUpdateView.as_view(), name='order-update'),

    # 用户发布的商品列表：GET /user/products/
    path('user/products/', UserProductsListView.as_view(), name='user-products-list'),
]